package com.appkubes.mall.restful.application.system.config.service.impl;

import com.appkubes.mall.core.entity.MallSystemConfig;
import com.appkubes.mall.core.service.impl.BaseMallSystemConfigServiceImpl;
import com.appkubes.mall.restful.application.system.config.dao.ConfigDao;
import com.appkubes.mall.restful.application.system.config.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ConfigServiceImpl extends BaseMallSystemConfigServiceImpl implements ConfigService {

    @Autowired
    ConfigDao configDao;

    public MallSystemConfig getByKey(String key) {
        MallSystemConfig query = new MallSystemConfig();
        query.setGlobalConfigKey(key);
        MallSystemConfig entity = this.getOneByEntity(query);
        return entity;
    }


    public String getByKey(String key, String value) {
        MallSystemConfig query = new MallSystemConfig();
        query.setConfigKey(key);
        MallSystemConfig config = this.getOneByEntity(query);
        if (config != null) {
            return config.getConfigValue();
        }
        return value;
    }


}
